// 数组来stack
class ArrayStack {
    #stack;
    constructor() {
        this.#stack = [];
    }
    get size() {
        return this.#stack.length;
    }
    isEmpty() {
        return this.size === 0;
    }
    push(element) {
        this.#stack.push(element);
    }
    pop() {
        if (this.isEmpty()) throw new Error('Stack is empty');
        return this.#stack.pop();
    }
    peek() {
        if (this.isEmpty()) throw new Error('Stack is empty');
        return this.#stack[this.size - 1];
    }
    toArray() {
        return this.#stack;
    }
}